package com.clsz.bean.bo;


public class BaseSearchBo {
    private Integer page = 1; //当前页码
    private Integer pageSize = 10;  //每页条数
    private Integer startIndex = 0; //起始页码
    private Integer resultCount = 0; //总条数
    private Integer pageCount = 0; //总页数

    private String orderColumn;
    private String orderType;


    public BaseSearchBo() {
    }

    public BaseSearchBo(Integer page, Integer pageSize, Integer startIndex, Integer resultCount, Integer pageCount) {
        this.page = page;
        this.pageSize = pageSize;
        this.startIndex = startIndex;
        this.resultCount = resultCount;
        this.pageCount = pageCount;
    }

    public BaseSearchBo(Integer page, Integer pageSize, Integer startIndex, Integer resultCount, Integer pageCount, String orderColumn, String orderType) {
        this.page = page;
        this.pageSize = pageSize;
        this.startIndex = startIndex;
        this.resultCount = resultCount;
        this.pageCount = pageCount;
        this.orderColumn = orderColumn;
        this.orderType = orderType;
    }

    /**
     * 获取
     * @return page
     */
    public Integer getPage() {
        return page;
    }

    /**
     * 设置
     * @param page
     */
    public void setPage(Integer page) {
        this.page = page;
        setStartIndex((this.page-1)*this.pageSize);
    }

    /**
     * 获取
     * @return pageSize
     */
    public Integer getPageSize() {
        return pageSize;
    }

    /**
     * 设置
     * @param pageSize
     */
    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
        setStartIndex((this.page-1)*this.pageSize);
    }

    /**
     * 获取
     * @return startIndex
     */
    public Integer getStartIndex() {
        return startIndex;
    }

    /**
     * 设置
     * @param startIndex
     */
    public void setStartIndex(Integer startIndex) {
        this.startIndex = startIndex;
    }

    /**
     * 获取
     * @return resultCount
     */
    public Integer getResultCount() {
        return resultCount;
    }

    /**
     * 设置
     * @param resultCount
     */
    public void setResultCount(Integer resultCount) {
        this.resultCount = resultCount;
        System.out.println("==============================>"+this.resultCount);
        System.out.println("==============================>"+this.pageCount);
        setPageCount(
                this.resultCount%this.pageSize==0?(this.resultCount/this.pageSize):(this.resultCount/this.pageSize+1)
        );
    }

    /**
     * 获取
     * @return pageCount
     */
    public Integer getPageCount() {
        return pageCount;
    }

    /**
     * 设置
     * @param pageCount
     */
    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
        if (this.page > this.pageCount) {
            setPage(this.pageCount);
        }
        if (this.page < 1) {
            setPage(1);
        }
    }

    /**
     * 获取
     * @return orderColumn
     */
    public String getOrderColumn() {
        return orderColumn;
    }

    /**
     * 设置
     * @param orderColumn
     */
    public void setOrderColumn(String orderColumn) {
        this.orderColumn = orderColumn;
    }

    /**
     * 获取
     * @return orderType
     */
    public String getOrderType() {
        return orderType;
    }

    /**
     * 设置
     * @param orderType
     */
    public void setOrderType(String orderType) {
        this.orderType = orderType;
    }
}
